package com.dd.census.service.impl;

import com.dd.census.entity.Staff1;
import com.dd.census.mapper.Staff1Mapper;
import com.dd.census.service.Staff1Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 业务层实现类
 * Staff1ServiceImpl
 * @author whn
 * @date 2020/11/26
 */
@Service
public class Staff1ServiceImpl implements Staff1Service {

    @Autowired
	Staff1Mapper mapper;

    @Override
    public int insertStaff1(Staff1 staff1) {
        return mapper.insertStaff1(staff1);
    }

    @Override
    public int updateStaff1(Staff1 staff1) {
    	return mapper.updateStaff1(staff1);
    }

    @Override
    public int delete(Staff1 staff1) {
    	return mapper.delete(staff1);
    }

	@Override
	public Staff1 selectByKey(String id) {
		return mapper.selectByKey(id);
	}

	@Override
	public List<Staff1> selectList(Staff1 staff1) {
		return mapper.selectList(staff1);
	}

	@Override
	public Map<String, Object> selectPage(Staff1 staff1) {
		Map<String, Object> map = new HashMap<String, Object>();
		int total = this.total(staff1);
		map.put("pageCount", Math.ceil((double) total / staff1.getPageSize()));// 总页数
		map.put("total", total);// 总条数
		map.put("index", staff1.getPageIndex());// 当前页
		if (total > 0) {
			staff1.setPageIndex(staff1.getPageSize() * (staff1.getPageIndex() - 1));
			map.put("items", mapper.selectPage(staff1));
		}
		return map;
	}

	@Override
	public Map<String, Object> selectAllIt(Staff1 staff1) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("items", mapper.selectAllIt(staff1));
		return map;
	}

	@Override
	public int total(Staff1 staff1) {
		return mapper.total(staff1);
	}
}